<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <title>合同模板管理 - 人力资源管理系统</title>
  <link rel="stylesheet" href="styles.css">
  <style>
    /* 搜索区域样式 */
    .search-form {
      background: #fff;
      border: 1px solid var(--border-color);
      border-radius: 4px;
      padding: 24px;
      margin-bottom: 16px;
    }

    .search-form-grid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 24px;
    }

    .form-item {
      display: flex;
      align-items: center;
    }

    .form-label {
      font-size: 14px;
      color: var(--text-primary);
      margin-right: 8px;
      flex-shrink: 0;
      width: 70px;
      text-align: right;
    }

    .form-input, .form-select {
      flex: 1;
      height: 32px;
      padding: 0 12px;
      border: 1px solid var(--border-color);
      border-radius: 4px;
      font-size: 14px;
      background: #fff;
      width: calc(100% - 78px);
    }

    .search-buttons {
      display: flex;
      gap: 16px;
    }

    .action-buttons {
      margin-bottom: 16px;
      display: flex;
      gap: 12px;
    }

    /* 表格区域样式 */
    .table-container {
      background: #fff;
      border-radius: 4px;
      border: 1px solid var(--border-color);
    }

    table {
      width: 100%;
      border-collapse: collapse;
    }

    th, td {
      padding: 12px 16px;
      border-bottom: 1px solid var(--border-color);
      text-align: left;
    }

    th {
      background: #fafafa;
      font-weight: 600;
      color: var(--text-primary);
    }

    tr:hover {
      background: #fafafa;
    }

    .table-actions {
      display: flex;
      gap: 8px;
    }

    .table-actions button {
      padding: 4px 12px;
      font-size: 12px;
    }

    /* 分页控件样式 */
    .pagination {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      margin-top: 16px;
      gap: 8px;
      border: 1px solid #ff4d4f;
      border-radius: 2px;
      display: inline-flex;
      float: right;
      margin-top: 20px;
      margin-bottom: 20px;
    }
    
    .pagination button {
      min-width: 32px;
      height: 32px;
      border: none;
      background: #fff;
      cursor: pointer;
      font-size: 14px;
      color: var(--text-primary);
      display: flex;
      align-items: center;
      justify-content: center;
      margin: 0;
      padding: 0 12px;
    }
    
    .pagination button.active {
      background: var(--primary-color);
      color: #fff;
    }
    
    .pagination button:not(.active):hover {
      color: var(--primary-color);
    }
    
    .pagination button:first-child, .pagination button:last-child {
      padding: 0 8px;
      background: #f5f5f5;
      color: #666;
      border-right: 1px solid #eee;
      border-left: 1px solid #eee;
    }

    /* 保留原有的弹窗样式 */
    .modal-overlay {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.5);
      display: none;
      justify-content: center;
      align-items: center;
      z-index: 1000;
    }

    .modal-overlay.active {
      display: flex;
    }

    .modal-content {
      background: #fff;
      border-radius: 8px;
      width: 500px;
      max-height: 80vh;
      overflow-y: auto;
      padding: 24px;
      position: relative;
    }

    .modal-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 24px;
    }

    .modal-title {
      font-size: 18px;
      font-weight: 600;
      color: var(--text-primary);
      margin: 0;
    }

    .modal-close {
      font-size: 20px;
      color: var(--text-secondary);
      cursor: pointer;
      padding: 4px;
      line-height: 1;
    }

    .modal-form {
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    .modal-footer {
      margin-top: 24px;
      display: flex;
      justify-content: flex-end;
      gap: 12px;
    }

    .template-tips {
      background: #f5f7fa;
      border-radius: 4px;
      padding: 16px;
      margin-bottom: 16px;
    }

    .template-tips h4 {
      margin: 0 0 8px 0;
      color: #232a3b;
    }

    .template-tips ul {
      margin: 0;
      padding-left: 20px;
      color: #666;
    }

    .template-tips li {
      margin-bottom: 4px;
    }

    .template-tips code {
      background: #e6f7ff;
      padding: 2px 6px;
      border-radius: 4px;
      color: #40a9ff;
    }
    
    /* 响应式设计优化 */
    @media screen and (max-width: 1366px) {
      /* 搜索表单优化 */
      .search-form-grid {
        grid-template-columns: repeat(3, 1fr);
      }
      
      /* 内容区域padding调整 */
      .content {
        padding: 16px;
      }
      
      /* 表格内容溢出处理 */
      .table-container {
        overflow-x: auto;
      }
    }
    
    @media screen and (max-width: 1024px) {
      /* 搜索表单进一步优化 */
      .search-form-grid {
        grid-template-columns: repeat(2, 1fr);
      }
      
      /* 按钮区域调整 */
      .action-buttons {
        flex-wrap: wrap;
      }
    }
    
    @media screen and (max-width: 768px) {
      /* 搜索表单再次优化 */
      .search-form-grid {
        grid-template-columns: 1fr;
      }
      
      /* 表格操作按钮调整 */
      .table-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
      }
      
      /* 头部和尾部调整 */
      .topbar {
        padding: 0 16px;
      }
      
      /* 弹窗调整 */
      .modal-content {
        width: 95%;
        max-width: 95%;
        padding: 16px;
      }
      
      /* 表格内容适应 */
      table {
        font-size: 12px;
      }
      
      th, td {
        padding: 8px 10px;
      }
    }
    
    /* 表格横向滚动优化 */
    .table-container {
      width: 100%;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }
    
    /* 确保表格在横向滚动时表头固定 */
    .sticky-header th {
      position: sticky;
      top: 0;
      z-index: 10;
      background: #fafafa;
    }
  </style>
</head>
<body>
  <div class="layout">
    <!-- 使用公共侧边栏 -->
    <div id="sidebar-container"></div>

    <div class="main">
      <div class="topbar">
        <div class="title">合同模板管理</div>
        <div class="user">
          <span>管理员</span>
          <img src="https://via.placeholder.com/32x32.png?text=U" alt="用户头像">
        </div>
      </div>
      <div class="content">
        <div class="search-form">
          <div class="search-form-grid">
            <div class="form-item">
              <label class="form-label">模板名称</label>
              <input type="text" class="form-input" placeholder="请输入模板名称">
            </div>
            <div class="form-item">
              <label class="form-label">合同类型</label>
              <select class="form-select">
                <option value="">全部</option>
                <option value="1">劳动合同</option>
                <option value="2">实习合同</option>
                <option value="3">兼职合同</option>
              </select>
            </div>
            <div class="form-item">
              <label class="form-label">更新时间</label>
              <select class="form-select">
                <option value="">全部</option>
                <option value="1">最近一周</option>
                <option value="2">最近一月</option>
                <option value="3">最近三月</option>
              </select>
            </div>
            <div class="form-item search-buttons">
              <button type="button" class="btn btn-primary">搜索</button>
              <button type="button" class="btn btn-default">重置</button>
            </div>
          </div>
        </div>

        <div class="action-buttons">
          <button class="btn btn-primary">新增模板</button>
          <button class="btn btn-default">导入</button>
          <button class="btn btn-default">导出</button>
        </div>

        <div class="table-container">
          <table style="min-width: 1200px;">
            <thead class="sticky-header">
              <tr>
                <th width="25%">模板名称</th>
                <th width="15%">合同类型</th>
                <th width="10%">版本</th>
                <th width="15%">更新时间</th>
                <th width="20%">标签</th>
                <th width="15%">操作</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>标准劳动合同模板</td>
                <td>劳动合同</td>
                <td>v2.1</td>
                <td>2024-01-15</td>
                <td>
                  <span class="template-tag">劳动合同</span>
                  <span class="template-tag">全职</span>
                </td>
                <td class="table-actions">
                  <button class="btn btn-default">预览</button>
                  <button class="btn btn-default">编辑</button>
                  <button class="btn btn-default">使用</button>
                </td>
              </tr>
              <tr>
                <td>实习生合同模板</td>
                <td>实习合同</td>
                <td>v1.5</td>
                <td>2024-01-10</td>
                <td>
                  <span class="template-tag">实习合同</span>
                  <span class="template-tag">校园招聘</span>
                </td>
                <td class="table-actions">
                  <button class="btn btn-default">预览</button>
                  <button class="btn btn-default">编辑</button>
                  <button class="btn btn-default">使用</button>
                </td>
              </tr>
              <tr>
                <td>兼职员工合同模板</td>
                <td>兼职合同</td>
                <td>v1.2</td>
                <td>2024-01-05</td>
                <td>
                  <span class="template-tag">兼职合同</span>
                  <span class="template-tag">灵活用工</span>
                </td>
                <td class="table-actions">
                  <button class="btn btn-default">预览</button>
                  <button class="btn btn-default">编辑</button>
                  <button class="btn btn-default">使用</button>
                </td>
              </tr>
              <tr>
                <td>服务外包合同模板</td>
                <td>服务合同</td>
                <td>v1.8</td>
                <td>2024-01-20</td>
                <td>
                  <span class="template-tag">服务合同</span>
                  <span class="template-tag">外包</span>
                </td>
                <td class="table-actions">
                  <button class="btn btn-default">预览</button>
                  <button class="btn btn-default">编辑</button>
                  <button class="btn btn-default">使用</button>
                </td>
              </tr>
              <tr>
                <td>保密协议模板</td>
                <td>保密协议</td>
                <td>v2.0</td>
                <td>2024-01-25</td>
                <td>
                  <span class="template-tag">保密协议</span>
                  <span class="template-tag">法务</span>
                </td>
                <td class="table-actions">
                  <button class="btn btn-default">预览</button>
                  <button class="btn btn-default">编辑</button>
                  <button class="btn btn-default">使用</button>
                </td>
              </tr>
              <tr>
                <td>销售合同模板</td>
                <td>服务合同</td>
                <td>v1.6</td>
                <td>2024-01-30</td>
                <td>
                  <span class="template-tag">服务合同</span>
                  <span class="template-tag">销售</span>
                </td>
                <td class="table-actions">
                  <button class="btn btn-default">预览</button>
                  <button class="btn btn-default">编辑</button>
                  <button class="btn btn-default">使用</button>
                </td>
              </tr>
              <tr>
                <td>采购合同模板</td>
                <td>采购合同</td>
                <td>v1.4</td>
                <td>2024-02-05</td>
                <td>
                  <span class="template-tag">采购合同</span>
                  <span class="template-tag">供应链</span>
                </td>
                <td class="table-actions">
                  <button class="btn btn-default">预览</button>
                  <button class="btn btn-default">编辑</button>
                  <button class="btn btn-default">使用</button>
                </td>
              </tr>
              <tr>
                <td>试用期合同模板</td>
                <td>劳动合同</td>
                <td>v1.9</td>
                <td>2024-02-10</td>
                <td>
                  <span class="template-tag">劳动合同</span>
                  <span class="template-tag">试用期</span>
                </td>
                <td class="table-actions">
                  <button class="btn btn-default">预览</button>
                  <button class="btn btn-default">编辑</button>
                  <button class="btn btn-default">使用</button>
                </td>
              </tr>
              <tr>
                <td>顾问合同模板</td>
                <td>顾问合同</td>
                <td>v1.3</td>
                <td>2024-02-15</td>
                <td>
                  <span class="template-tag">顾问合同</span>
                  <span class="template-tag">咨询</span>
                </td>
                <td class="table-actions">
                  <button class="btn btn-default">预览</button>
                  <button class="btn btn-default">编辑</button>
                  <button class="btn btn-default">使用</button>
                </td>
              </tr>
              <tr>
                <td>项目合作协议模板</td>
                <td>框架协议</td>
                <td>v1.7</td>
                <td>2024-02-20</td>
                <td>
                  <span class="template-tag">框架协议</span>
                  <span class="template-tag">项目合作</span>
                </td>
                <td class="table-actions">
                  <button class="btn btn-default">预览</button>
                  <button class="btn btn-default">编辑</button>
                  <button class="btn btn-default">使用</button>
                </td>
              </tr>
              <tr>
                <td>外籍员工合同模板</td>
                <td>劳动合同</td>
                <td>v1.5</td>
                <td>2024-02-25</td>
                <td>
                  <span class="template-tag">劳动合同</span>
                  <span class="template-tag">外籍人员</span>
                </td>
                <td class="table-actions">
                  <button class="btn btn-default">预览</button>
                  <button class="btn btn-default">编辑</button>
                  <button class="btn btn-default">使用</button>
                </td>
              </tr>
              <tr>
                <td>高管合同模板</td>
                <td>劳动合同</td>
                <td>v2.2</td>
                <td>2024-03-01</td>
                <td>
                  <span class="template-tag">劳动合同</span>
                  <span class="template-tag">高管</span>
                </td>
                <td class="table-actions">
                  <button class="btn btn-default">预览</button>
                  <button class="btn btn-default">编辑</button>
                  <button class="btn btn-default">使用</button>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
        <div class="pagination">
          <button>上一页</button>
          <button class="active">1</button>
          <button>2</button>
          <button>3</button>
          <button>下一页</button>
        </div>
      </div>
    </div>
  </div>

  <!-- 新增模板弹窗 -->
  <div class="modal-overlay" id="newTemplateModal">
    <div class="modal-content">
      <div class="modal-header">
        <h3 class="modal-title">新建合同模板</h3>
        <span class="modal-close" onclick="hideNewTemplateModal()">×</span>
      </div>
      <div class="template-tips">
        <h4>模板变量说明</h4>
        <ul>
          <li>${name} - 合同方姓名</li>
          <li>${contractNumber} - 合同编号</li>
          <li>${startDate} - 合同开始日期</li>
          <li>${endDate} - 合同结束日期</li>
          <li>${position} - 职位名称</li>
          <li>${department} - 部门名称</li>
          <li>${salary} - 薪资金额</li>
          <li>${companyName} - 公司名称</li>
          <li>${legalRepresentative} - 法定代表人</li>
        </ul>
      </div>
      <div class="modal-form">
        <div class="form-item">
          <label class="form-label">模板名称</label>
          <input type="text" class="form-input" placeholder="请输入模板名称">
        </div>
        <div class="form-item">
          <label class="form-label">合同类型</label>
          <select class="form-select">
            <option value="formal">正式合同</option>
            <option value="internship">实习合同</option>
            <option value="labor">劳务合同</option>
            <option value="confidentiality">保密协议</option>
            <option value="service">服务合同</option>
            <option value="purchase">采购合同</option>
            <option value="framework">框架协议</option>
          </select>
        </div>
        <div class="form-item">
          <label class="form-label">上传模板文件</label>
          <input type="file" accept=".doc,.docx,.pdf" class="form-input">
        </div>
      </div>
      <div class="modal-footer">
        <button class="search-button" onclick="hideNewTemplateModal()">取消</button>
        <button class="search-button primary">确定</button>
      </div>
    </div>
  </div>

  <script src="js/common.js"></script>
  <script>
    // 页面加载完成后加载组件
    document.addEventListener('DOMContentLoaded', loadComponents);

    // 其他页面特定的 JavaScript 代码
    // 打开弹窗
    function showNewTemplateModal() {
      document.getElementById('newTemplateModal').classList.add('active');
    }

    // 关闭弹窗
    function hideNewTemplateModal() {
      document.getElementById('newTemplateModal').classList.remove('active');
    }
  </script>
</body>
</html> 